package edu.nf.ch06.easy;

import edu.nf.ch06.product.IPhone;
import edu.nf.ch06.product.MiPhone;

/**
 * @author wangl
 * @date 2025/4/15
 * 简单工厂
 */
public class ObjectFactory {

    public Object create(String name) {
        if ("apple".equals(name)) {
            return new IPhone();
        } else if ("xiaomi".equals(name)) {
            return new MiPhone();
        } else {
            throw new IllegalArgumentException("unknown phone: " + name);
        }
    }
}